//****************************************************************************
//
// suspend & resume example
//
//****************************************************************************

#configure board        hu_arm_v4
#configure clcd_lines   2
#configure memory       rom
#configure baudrate     38400

#include "pRTOS.h"
#include "armboard.h"

int main( void ){
   RTOS::run();
   return 0;
}

// end of standard part

class beeper : public RTOS::task {
private:
   armboard::output_pin & speaker;
public:
   beeper( armboard::output_pin & speaker ): speaker( speaker ){}
   void main( void ){
   speaker.direction_set_output();
      for(;;){
         speaker.set( 1 );
         armboard::wait( 500 );
         speaker.set( 0 );
         armboard::wait( 500 );
      }
   }
};
beeper speaker( armboard::chip::pin_0_8 );

class suspender : public RTOS::task {
   void main( void ){
      for( int i = 0; i < 5 ; i++ ){
         speaker.resume();
         sleep( 500 MS );
         speaker.suspend();
         sleep( 1 S );
      }
      suspend();
   }
};
suspender task2;

